<template>
  <div class="content">
    <div class="item" v-for="item in collection" :key="item.id" @click="toPath(item)">
      <img :src="item.imgUrl" alt="" />
      <span class="label">{{ item.label }}</span>
      <span class="detail">{{ item.detail }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

let selectedMember = ref<any>([])

const getImageUrl = (name: string): any => {
  return new URL(`../../assets/img/${name}.png`, import.meta.url).href
}

let collection = reactive<any>([
  {
    id: 1,
    imgUrl: getImageUrl('auto_add_friend'),
    label: '自动添加好友',
    detail: '导入客户手机号自动发送好友邀请',
    path: '/auto-add-buddy'
  },
  {
    id: 2,
    imgUrl: getImageUrl('add_group_friend'),
    label: '加群好友',
    detail: '一键编辑添加进群好友',
    path: '/add-group-buddy'
  },
  {
    id: 3,
    imgUrl: getImageUrl('infinite_group'),
    label: '无限群发',
    detail: '无限次企业微信消息群发',
    path: '/infinite-send'
  },
  {
    id: 4,
    imgUrl: getImageUrl('publish_group_notice'),
    label: '发布群公告',
    detail: '一键批量发布群公告',
    path: '/publishGroupNotice'
  },
  {
    id: 5,
    imgUrl: getImageUrl('group_monitor'),
    label: '群发监控助手',
    detail: '帮助员工监控群发任务、自动执行员工群发',
    path: '/groupMonitor'
  },
  {
    id: 6,
    imgUrl: getImageUrl('auto_reply'),
    label: '智能回复',
    detail: '根据客户聊天关键词，自动回复消息内容',
    path: '/smartReply'
  }
])

const toPath = (item: any) => {
  const { path } = item
  router.push({ path })
}
</script>

<style scoped lang="scss">
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #0433ff;
  color: #fff;
  padding: 0 10px;
  box-sizing: border-box;

  .left {
    display: flex;
    align-items: center;

    .data {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      padding: 4px;
      border-radius: 6px;

      &:hover {
        cursor: pointer;
        background-color: #294ff5;
      }

      .icon {
        font-size: 28px;
      }

      span {
        font-size: 12px;
        line-height: 2;
      }
    }

    .avatar {
      width: 48px;
      height: 48px;
      border-radius: 8px;
      background-color: #f6f6f6;
      overflow: hidden;
      margin: 14px;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .info {
      display: flex;
      flex-direction: column;
      font-size: 13px;

      span {
        line-height: 1;
      }

      .name {
        margin-bottom: 8px;
      }

      .corp {}
    }
  }

  .right {}
}

.title {
  height: 40px;
  background-color: #fff;
  display: flex;
  align-items: center;
  padding: 0 10px;
  box-shadow: 0 20px 20px #eee;
  font-size: 13px;
  letter-spacing: 1px;
  color: #555;
}

.content {
  // display: flex;
  // flex-wrap: wrap;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-gap: 16px;

  .item {
    // width: 22%;
    height: 176px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 20px #ddd;
    // margin-right: 16px;
    // padding-bottom: 16px;
    grid-gap: 0;

    &:hover {
      cursor: pointer;
    }

    img {
      width: 100%;
      height: 100px;
    }

    &>span {
      width: 100%;
      text-align: center;
      line-height: 1;
      font-size: 12px;
      font-weight: 300;
      color: #666;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .label {
      margin: 14px 0;
      font-size: 14px;
      font-weight: 500;
    }

    .detail {}
  }
}
</style>
